package com.codefish.controller;

import java.util.Arrays;

import com.codefish.entity.SysPermissionApiEntity;
import com.codefish.service.SysPermissionApiService;
import com.codefish.util.R;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;



/**
 * 权限与接口
 *
 * @author codefish
 * @email code_fish@aliyun.com
 * @date 2021-04-15 04:22:58
 */
@RestController
@RequestMapping("/sysPermissionApi")
public class SysPermissionApiController {
    @Autowired
    private SysPermissionApiService sysPermissionApiService;



    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("generator:syspermissionapi:info")
    public R info(@PathVariable("id") Long id){
		SysPermissionApiEntity sysPermissionApi = sysPermissionApiService.getById(id);

        return R.ok().put("sysPermissionApi", sysPermissionApi);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("generator:syspermissionapi:save")
    public R save(@RequestBody SysPermissionApiEntity sysPermissionApi){
		sysPermissionApiService.save(sysPermissionApi);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("generator:syspermissionapi:update")
    public R update(@RequestBody SysPermissionApiEntity sysPermissionApi){
		sysPermissionApiService.updateById(sysPermissionApi);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("generator:syspermissionapi:delete")
    public R delete(@RequestBody Long[] ids){
		sysPermissionApiService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
